package com.sskj.mine.router.service;

import android.content.Context;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpHeaders;
import com.sskj.common.base.AppManager;
import com.sskj.common.util.SPUtil;
import com.sskj.lib.RConfig;
import com.sskj.lib.model.room.UserViewModel;
import com.sskj.lib.router.provider.LogoutProvider;
import com.sskj.mine.component.DaggerUserDataComponent;

import javax.inject.Inject;

@Route(path = "/mine/service/logout")
public class LogoutProviderImpl implements LogoutProvider {
    @Inject
    UserViewModel userViewModel;

    @Override
    public void logout() {
        DaggerUserDataComponent.create().inject(this);
        SPUtil.clear();
        HttpHeaders commonHeaders = OkGo.getInstance().getCommonHeaders();
        commonHeaders.clear();
        OkGo.getInstance().addCommonHeaders(commonHeaders);
        userViewModel.clear();

        AppManager.getAppManager().finishAllActivity("com.sskj.jingbi.ui.activity.MainActivity");
        ARouter.getInstance().build(RConfig.LOGIN_LOGIN).navigation();



    }

    @Override
    public void init(Context context) {

    }
}
